package org.gordonframework.site.forms.elements {
	import org.gordonframework.site.events.GFormElementEvent;
	import org.gordonframework.site.forms.elements.GElement;
	
	import flash.events.MouseEvent;		

	/**
	 * @author eriarv
	 */
	public class GButton extends GElement {
		
		public static const SUBMIT : String = "submit";
		public static const TYPE : String = "Button";
		
		private var _disabled : Boolean;

		public function GButton(id : String, value : String = "", mandatory : Boolean = false, text : String = "", disabled : Boolean = false, skinClass : Class = null) {
			_disabled = disabled;
			super(TYPE, id, value, mandatory, text, skinClass);
			skin.addEventListener(MouseEvent.CLICK, clickHandler);
		}
		
		private function clickHandler(event : MouseEvent) : void {
			dispatchEvent(new GFormElementEvent( GFormElementEvent.CLICK ));
		}
		

		public function get disabled() : Boolean {
			return _disabled;
		}
		
		public function set disabled(disabled : Boolean) : void {
			_disabled = disabled;
		}
	}
}
